package pl.com.hme.kody.pocztowe.test;

import com.jayway.android.robotium.solo.Solo;

import pl.com.hme.kody.pocztowe.ui.HomeActivity;
import android.test.ActivityInstrumentationTestCase2;
import android.test.suitebuilder.annotation.SmallTest;

public class MainScreenTestCase extends ActivityInstrumentationTestCase2<HomeActivity> {
	private Solo mSolo;
	
	public MainScreenTestCase() {
		super("pl.com.hme.kody.pocztowe.ui.HomeActivity", HomeActivity.class);
	}

	@Override
	protected void setUp() throws Exception {
		super.setUp();
		mSolo = new Solo(getInstrumentation(), getActivity());
	}

	@SmallTest
	public void testIncorretDataInForm() {
		mSolo.clickOnButton(getActivity().getString(pl.com.hme.kody.pocztowe.R.string.search_button));
		
        boolean toastIsShownInvalid = mSolo.searchText(getActivity().getString(pl.com.hme.kody.pocztowe.R.string.invalid_data_in_form)); 

        assertTrue("Dialog with success message is not shown", toastIsShownInvalid); 
        
	}
	
	
	@Override
	protected void tearDown() throws Exception {
		try {
			mSolo.finalize();
		} catch (Throwable e) {
			e.printStackTrace();
		}
		getActivity().finish();
		super.tearDown();
	}
}
